import { NavigateService } from './../../service/navigate.service';
import { SystemService } from './../../service/system.service';
import { Component, OnInit } from '@angular/core';
@Component({
    selector: "div[update]",
    templateUrl: "./update.component.html",
    styleUrls: ["./update.component.scss"]
})
export class UpdateComponent implements OnInit {
    latestVersion: any = {
        version: "",
        changeLogs: ""
    };
    lastVersion: string = "";
    changeLogs: string[] = [];
    constructor(
        private sysSvr: SystemService
    ) { }
    async ngOnInit() {
        let versionInfo: any = this.sysSvr.getVersion();
        let latestVersionInfo = this.sysSvr.getLatestVersion();
        if (latestVersionInfo) {
            latestVersionInfo.then(response => {
                let versionData = response.json();
                this.latestVersion = versionData;
                this.changeLogs = this.latestVersion.changeLogs.split("#");
            });
        }
        if (versionInfo) {
            versionInfo.then(response => {
                let versionData = response.json();
                this.lastVersion = versionData;
            });
        }
    }

    confirmUpdate() {
        window.location.href = "../install.html";
    }
}